package com.c.ctgproject.adapter.storage

import android.content.Context
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.TextView
import androidx.recyclerview.widget.RecyclerView
import com.c.ctgproject.R
import com.c.ctgproject.entity.storage.StoragePartsOutEntity

/**
 *作者:LiBW
 *创建日期: 2020/9/15
 *描述:仓库 配件列表详情 adapter
 */
class StoragePartDetailAdapter(private val context: Context, private val mList: List<StoragePartsOutEntity.DataBean.ListBean.PartsInfosBean>) : RecyclerView.Adapter<StoragePartDetailAdapter.ViewHolder>() {
    override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ViewHolder {
        val view = LayoutInflater.from(context).inflate(R.layout.item_storage_part_detail_list, parent, false)
        return ViewHolder(view)
    }

    override fun getItemCount(): Int {
        return mList.size
    }

    override fun onBindViewHolder(holder: ViewHolder, position: Int) {
        val data = mList[position]
        holder.mPartNameTV.text = data.partsName.toString()
        holder.mPriceTV.text = data.partsPrice.toString()
        holder.mCountTV.text = data.partsNumber.toString()
    }

    inner class ViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView) {
        val mPartNameTV: TextView = itemView.findViewById(R.id.mPartNameTV)
        val mPriceTV: TextView = itemView.findViewById(R.id.mPriceTV)
        val mCountTV: TextView = itemView.findViewById(R.id.mCountTV)
    }
}